import request from '@/api/request.js';

const key = '6f5e88ec2764db25e3e75a718effe617';

// 通过 ip 地址查询所在城市
export const getCityByIp = () => {
  return request({
    url: `/ip?key=${key}`,
    method: 'get',
  });
};

//通过城市名查询 adcode
export const getAdcodeByCity = city => {
  return request({
    url: `/geocode//geo?address=${city}&key=${key}`,
    method: 'get',
  });
};

//通过 adcode 查询城市天气
export const getWeatherByAdcode = adcode => {
  return request({
    url: `/weather/weatherInfo?city=${adcode}&key=${key}&extensions=all`,
  });
};

//通过 adcode 查询城市实时天气
export const getRealtimeWeatherByAdcode = adcode => {
  return request({
    url: `/weather/weatherInfo?city=${adcode}&key=${key}&extensions=base`,
  });
};
